package kr.co.skplanet.commute.dao;

import kr.co.skplanet.commute.domain.User;
import kr.co.skplanet.commute.repository.hibernate.HibernateGenericRepository;

import org.hibernate.Criteria;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;


@Repository(value = "userDAO")
public class UserDAO extends HibernateGenericRepository<User>{
	public UserDAO(){

	}
	public boolean rowExists(String column, String data) {
		Criteria criteria = getCriteria();
		criteria.setProjection(Projections.property(column));
		criteria.add(Restrictions.eq(column, data));
		
		String retData = (String) criteria.uniqueResult();
		if( retData == null  || retData == "" ) {
			getCurrentSession().clear();
			return false;
		}else{
			getCurrentSession().clear();
			return true;
		}
	}
}
